<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网格布局-对齐方式</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .box {
            display: grid;
            width: 600px;
            height: 600px;
            border: 5px solid gray;
            grid-template-columns: repeat(3, 100px);
            grid-template-rows: repeat(3, 100px);
            /*从左到右排列改成从上到下排列*/
            grid-auto-flow: column;
            /* 水平对齐方式 */
            /* justify-content: center;  */
            /* 垂直对齐方式 */
            /* align-content: center;  */
            /* 水平和垂直对齐方式 */
            place-content: center; 
            /* 网格项的对齐方式 */
            /* align-items: center;  */
            /* 网格项的水平对齐方式 */
            /* justify-items: center;  */
            /* 网格项的水平和垂直对齐方式 */
            place-items: center; 
        }
        .item {
            border: 1px solid red;
            box-sizing: border-box;
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
        <div class="item">5</div>
        <div class="item">6</div>
        <div class="item">7</div>
        <div class="item">8</div>
        <div class="item">9</div>
    </div>
</body>
</html>